﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Fierce.Core.Aop;
using Fierce.Entity.Basic;

namespace Fierce.Core.Service.Basic
{
    public partial class BasicRoleService : OrderService<BasicRole>
    {
        public virtual List<BasicRole> Grid(int rows, int page, out int count)
        {
            return db.BasicRole.Pager(rows, page, out count).ToList();
        }

        public virtual ServiceResult EnableOrDisable(string id, bool bit)
        {
            BasicRole entity = db.BasicRole.Get(id);

            if (entity != null)
            {
                if (entity.IsEnabled != bit)
                {
                    entity.IsEnabled = bit;

                    db.BasicRole.Modified(entity);

                    return SaveAndResult(bit ? "启用成功" : "禁用成功");
                }
                else
                {
                    return FailureResult(bit ? "已经是启用状态" : "已经是禁用状态");
                }
            }

            return FailureResult();
        }
    }
}
